package _3ChapterThree._3ChangeValueToReference.newObject;

import java.util.HashMap;
import java.util.Map;

public class Customer {
    private final String _name;

    private static final Map<String, Customer> _instances = new HashMap<>();

    public static Customer create(String customerName) {
        return _instances.get(customerName);
    }

    private Customer(String _name) {
        this._name = _name;
    }

    public String get_name() {
        return _name;
    }

    private void store() {
        _instances.put(this.get_name(), this);
    }

    public static void loadCustomer() {
        new Customer("LiLe").store();
        new Customer("Nice").store();
        new Customer("Lucy").store();
    }

}
